from flask import jsonify
from . import api_bp
from models import get_all_permissions

@api_bp.route('/permissions')
def permissions():
    permissions = get_all_permissions()
    # 转换为字典格式
    permissions_list = []
    for permission in permissions:
        permissions_list.append({
            'id': permission[0],
            'name': permission[1],
            'code': permission[2],
            'description': permission[3],
            'category': permission[4],
            'created_at': permission[5]
        })
    return jsonify(permissions_list)